package com.iona.json.builders;

import java.util.List;

import com.iona.domain.TypeStudyWork;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class TypeStudyWorkBuilder extends JSONBuilder {

	private final List<TypeStudyWork> typeStudyWorks;

	public TypeStudyWorkBuilder(List<TypeStudyWork> findAll) {
		this.typeStudyWorks = findAll;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (TypeStudyWork tsw : typeStudyWorks) {
			System.out.println(tsw.getShortname());
			JSONArray arr = new JSONArray();
			arr.put(tsw.getId());
			arr.put(tsw.getShortname());
			root.put(arr);
		}
		return root;
	}

	@Override
	public String name() {
		return getClass().getSimpleName();
	}

}
